<template>
  <div class="input-properties">
    <el-form label-position="top">
      <el-form-item label="占位文本">
        <el-input
          v-model="properties.placeholder"
          placeholder="请输入占位文本"
          @change="updateProperties" />
      </el-form-item>
      
      <el-form-item>
        <el-checkbox
          v-model="properties.clearable"
          @change="updateProperties">
          显示清除按钮
        </el-checkbox>
      </el-form-item>
      
      <el-form-item>
        <el-checkbox
          v-model="properties.disabled"
          @change="updateProperties">
          禁用状态
        </el-checkbox>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'

const props = defineProps({
  value: {
    type: Object,
    default: () => ({
      placeholder: '请输入',
      clearable: true,
      disabled: false
    })
  }
})

const emit = defineEmits(['update'])

const properties = ref({ ...props.value })

watch(() => props.value, (newVal) => {
  properties.value = { ...newVal }
}, { deep: true })

const updateProperties = () => {
  emit('update', { ...properties.value })
}
</script> 